<?php

namespace app\controller\v1;

use app\model\OrderModel;
use app\validate\ProductionValidate;
use app\validate\WarehouseValidate;

class Production extends System
{

    /**
     * Notes: 生产部门 订单列表
     * User: chenLei
     * Date: 10/27/25 11:09:17
     * @return \think\response\Json
     */
    public function list()
    {
        $orderModel = new OrderModel();
        $res = $orderModel->productionList($this->params);

        return $this->successJson('ok', $res);
    }


    /**
     * Notes: 生产完成
     * User: chenLei
     * Date: 10/27/25 11:28:00
     * @return \think\response\Json
     */
    public function productionComplete()
    {
        $validate = new ProductionValidate();
        if (!$validate->scene('productionComplete')->check($this->params)) {
            return $this->errorJson($validate->getError());
        }

        $orderModel = new OrderModel();
        $res = $orderModel->productionComplete($this->params);

        if ($res === false) {
            return $this->errorJson($orderModel->getError());
        }

        return $this->successJson('ok');

    }


    /**
     * Notes: 详情
     * User: chenLei
     * Date: 10/27/25 12:00:43
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function info()
    {
        $validate = new ProductionValidate();
        if (!$validate->scene('info')->check($this->params)) {
            return $this->errorJson($validate->getError());
        }

        $orderModel = new OrderModel();
        $res = $orderModel->info($this->params);

        if ($res === false) {
            return $this->errorJson($orderModel->getError());
        }

        return $this->successJson($res);
    }
}